/*
 * DatePeriod.java
 *
 * Created on 24 marzec 2007, 16:38
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package util;

import java.util.Date;

/**
 *
 * @author xavex
 */
public class DatePeriod {

    private Date from;
    private Date to;
    
    /**
     * @param from
     * @param to
     */
    public DatePeriod(Date from, Date to) {
        this.from = from;
        this.to = to;
    }


    public boolean overlaps( DatePeriod p ) {
     
        return !(p.from.after( to ) || p.to.before( from ));
    }    
    
    public boolean contains( Date d )
    {
        return (d.equals( from )) || ( d.equals( to )) ||
               (from.before( d ) && to.after( d ) );
    }

    public Date getFrom() {
        return this.from;
    }

    public void setFrom(final Date from) {
        this.from = from;
    }

    public Date getTo() {
        return this.to;
    }

    public void setTo(final Date to) {
        this.to = to;
    }
}
